<template>
	<view class="content">
		<view class="content">
			<my-top v-if="identity == '班主任'" :url="this.bzrUrl" :topName="topName" :userName="userName"></my-top>
			<my-top v-else :url="this.url" :topName="topName" :userName="userName"></my-top>
			<view class="indexContent">
				<head-title :titleHead="titleHead" :btnFont="btnFont"></head-title>
				<!-- 	<view class="dormitoryNav">
						<view style="font-weight: 800;font-size: 42rpx;">全部信息
							<view class="leaveLine" ></view>
						</view>
					</view> -->
				<view v-if="leaveArr.length>0" style="margin-top:-40rpx">
					<view v-for="(item,index) in leaveArr" :key="index" @click="leaveIndexSkip(item)">
						<view class="mainContentWrap">
							<view style="color:#0000FF;font-weight: 800;font-size: 30rpx;">

								{{item.className}}
							</view>
							<view style="color:#8F8F94;font-size:28rpx">
								{{item.patrolTime}}
							</view>
							<!-- <view @click.stop="del(item)"
									style="margin-top:40rpx;color:#ff0088;font-weight: 800;font-size: 32rpx;width:90rpx">删除
								</view> -->
							<view style="color:#ff0088;font-size: 26rpx;text-align: right;flex-wrap: nowrap;">

								<!-- <view >(应到{{item.total}}人) </view> -->
								<view>(实到{{JSON.parse(item.classPatrolJson).actArriveNum}}人)</view>
								<!-- <view>({{item.withoutCard}}人未带工装工牌)</view> -->
								<!-- <view>({{item.novel}}人小说)</view>
									<view>({{item.film}}人小说)</view> -->
							</view>
							<!-- 						<view v-else
									style="margin-top:40rpx;color:#888;font-size: 30rpx;width:190rpx;text-align: right;flex-wrap: nowrap;">
		
									{{item.type}}
								</view> -->
						</view>
					</view>
					<view class="repDevice" v-if="loadMore">没有更多数据了</view>
				</view>
				<view v-else class="repDevice">暂无违纪记录</view>
			</view>
			<!-- <bottom-com :topName="topName" :bottomArr="attendanceArr" :bottomName="bottomName"></bottom-com> -->
			<!-- <my-bottom  :topName="topName" :bottomArr="attendanceArr" :bottomName="bottomName" ></my-bottom> -->

		</view>
	</view>
</template>

<script>
	import topCom from '@/pages/component/topCom.vue'
	import bottomCom from '@/pages/component/bottom.vue'
	import headTitle from '@/pages/component/btnHeadeCom.vue'
	export default {
		name: 'leveRegistration',
		data() {
			return {
				identity: "",
				bzrUrl: "/pages_main/dutyCheckWorkAttendance/dutyTecIndex",
				url:"/pages_main/dutyCheckWorkAttendance/dutyIndex/dutyIndex",
				loadMore: false,
				userName: '',
				topName: '晚自习巡查',
				btnFont: "晚自习登记",
				titleHead: '记录列表',
				leaveArr: [

				],
				id: '',
				attendanceArr: [{
						name: 'home',
						icon: 'iconfont icon-yonghutongji',
						text: "考勤",
						path: '/pages_main/dutyCheckWorkAttendance/dutyIndex/dutyIndex'
					},
					{
						name: 'atttendance',
						icon: 'iconfont icon-bi',
						text: "统计",
						path: '/pages_main/dutyCheckWorkAttendance/dutyIndex/dutyIndex'
					},
					{
						name: 'maintenance',
						icon: 'iconfont icon-shezhi',
						text: "设置",
						path: '/pages_main/dutyCheckWorkAttendance/dutyIndex/dutyIndex'
					}
				],
				attendanceTecArr: [{
						name: 'home',
						icon: 'iconfont icon-yonghutongji',
						text: "违纪",
						path: '/pages_main/dutyCheckWorkAttendance/dutyTecIndex'
					},
					{
						name: 'atttendance',
						icon: 'iconfont icon-bi',
						text: "统计",
						path: '/pages_main/dutyCheckWorkAttendance/dutyTecIndex'
					},
					{
						name: 'maintenance',
						icon: 'iconfont icon-shezhi',
						text: "设置",
						path: '/pages_main/dutyCheckWorkAttendance/dutyTecIndex'
					}
				],
				roleName: '',
				pageSize: 10,
				pageNum: 1,
			}
		},
		onLoad() {
			this.identity = uni.getStorageSync("userInfo")
			console.log(this.identity)
		},
		onReachBottom() {
			if (this.total >= this.pageNum * this.pageSize) {
				this.pageNum++
				this.getData();

			} else {
				this.loadMore = true
			}

		},
		components: {
			topCom,
			bottomCom,
			headTitle,
		},
		created() {
			var that = this
			uni.getStorage({
				key: "dutyDept",
				success: (res) => {
					that.id = res.data
				}
			})
			uni.getStorage({
					key: "loginName",
					success: (res) => {
						that.userName = res.data
					}
				}),
				uni.getStorage({
					key: "userInfo",
					success: (res) => {
						that.roleName = res.data
					}
				})
		},
		async mounted() {
			// this.getClassData()
			this.getData();
			// .then( res=>{
			// 	console.log(res);
			// 	this.leaveArr = res.data.list
			// 	this.total  =res.data.total;

			// 	this.leaveArr =await this.leaveArr.map(item=>{
			// 		console.log(item.classId)
			// 		uni.request({
			// 			url: uni.url + "Class/getBoardingStuCountByClassId?classId=" + item.classId,
			// 			success: res => {
			// 				console.log(res);
			// 				// item.total = res.data.data;
			// 				// return item;
			// 			}
			// 		})
			// 		return item;
			// 	})
			// 	// console.log(this.leaveArr)
			// })
		},
		methods: {
			async getData(){
					var res = await this.$api.duty.getSchoolPatrolPageList(5, this.pageSize, this.pageNum);
					this.leaveArr.push(...  res.data.list);
					this.total = res.data.total;
					
					
			},
			// 班级列表
			getClassData() {
				if (this.roleName == '部门经理') {
					this.$api.instructor.getAllAppClassList().then(res => {
						this.leaveArr = res.data


					})
				} else {
					this.$api.duty.getClassListByDept(this.id).then(res => {
						this.leaveArr = res.data
					}).catch(e => {

					})
				}


			},
			leaveIndexSkip(item) {
				
				
				var obj = JSON.stringify(item);
				uni.navigateTo({
					url: `/pages_main/dutyCheckWorkAttendance/dutyNightAttendanceDetail?obj=`+obj,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});


			}
		}
	}
</script>

<style>
	.repDevice {
		text-align: center;
		font-size: 32rpx;
		color: #808080;
		margin-top: 50rpx;
	}

	.mainContentWrap {
		border: #8F8F94 solid 0rpx;
		height: 120rpx;
		border-radius: 20rpx;
		margin-top: 30rpx;
		width: 680rpx;
		margin-left: 22rpx;
		box-shadow: 0upx 0upx 10upx 0upx #8F8F94;
		display: flex;
		justify-content: space-around;
		align-content: space-around;
		align-items: center;

	}

	.dormitoryNav {
		color: #0000FF;
		margin-left: 80rpx;
		margin-top: 30rpx;
	}

	.leaveLine {
		width: 200upx;
		height: 8upx;
		background: rgba(239, 220, 11, 1.0);
		opacity: 0.78;
		position: relative;
		bottom: -10rpx;
		left: -30upx;
	}

	.attBtn1 {
		margin-right: 4rpx;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top: -20rpx;
	}

	.leaveNav {
		display: flex;
		justify-content: center;
		align-items: center;
		flex-direction: row;
		font-size: 36upx;
		color: blue;
		width: 100%;
		padding: 50upx
	}

	.leaveBtn {
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		background-size: 100%;
		width: 190upx;
		height: 60upx;
		color: white;
		font-size: 26upx;
		font-weight: 0;
	}

	.leaveLine {
		width: 200upx;
		height: 8upx;
		background: rgba(239, 220, 11, 1.0);
		opacity: 0.78;
		position: relative;
		bottom: -10upx;
		left: -30upx;
	}

	.leaveMgm {
		color: #808080;
		font-size: 28upx;
	}

	.leaveCheck {
		margin-left: 60upx;
		margin-bottom: 30upx;

	}

	.attBtnFontSlec {
		border: solid #007AFF !important;
		border-radius: 15upx;
		font-size: 20upx;
		color: white;
		background-color: #007AFF;
	}

	.attBtnFont {
		border: solid #808080 0rpx !important;
		;
		font-size: 20upx;
	}

	.attBtnFont1 {
		border: solid #808080 0rpx !important;
		;
		font-size: 20upx;
		padding-left: 18rpx !important;
		padding-right: 18rpx !important;
	}

	.attLine {
		width: 700upx;
		height: 3upx;
		background: rgba(239, 237, 236, 1.0);
		opacity: 0.78;
		position: relative;
		bottom: 10upx;
		left: 0upx;
	}

	.attBtn {
		width: 60%;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top: -20upx;

	}

	.leaveBtn {
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/tubiao-01.png);
		width: 190upx;
		height: 60upx;
		color: white;
		font-size: 26upx;
		font-weight: 0;
	}

	.leaveLine {
		width: 220upx;
		height: 8upx;
		background: rgba(239, 220, 11, 1.0);
		opacity: 0.78;
		position: relative;
		bottom: -10rpx;
		left: -30upx;
	}

	.leaveMgm {
		color: #808080;
		font-size: 28upx;
	}

	.leaveCheck {
		margin-left: 60upx;
		margin-bottom: 30upx;
	}

	.checkout {
		display: flex;
		justify-content: space-around;
		align-content: space-between;
	}

	.leaveTabLine {
		width: 3upx;
		height: 60upx;
		background: #8F8F94;
		opacity: 0.78;
		position: relative;
		top: 0upx;
		left: 150upx;
	}
	.indexContent{
		height: unset !important
	}
</style>
